﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="frmConsultaMensagem.aspx.cs" Inherits="Sinacor.Tools.Web.ConstantesErro.ConsultaMensagem" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Consulta de mensagens</title>
    <link href="Estilos.css" rel="stylesheet" type="text/css" />
    <meta http-equiv="pragma" content="no-cache" />   
    
      <script type="text/javascript">
        function Trim(str){return str.replace(/^\s+|\s+$/g,"");}
        
        function DesabilitatBotao()
        {        
            document.getElementById('btnNovaMensagemResourceKey').disabled = 'true';
        }
        function ConfirmarDelete()
        {
         if(confirm('Confirma exclusão?'))
            return true;
         else
            return false;   
        }
        
        function ValidaCampos()
        {
            if(Trim(document.getElementById('txtMensagem').value) == "")
            {
                alert('Informe o texto para pesquisa!');
                return false;
            }
            else
                return true;
        }
                       
        function setUpdateItem(pObjTR)
        {
            /*
            Id
            Modulo
            Submodulo
            ResourceKey
            DescricaoMensagem
            Proposito
            DescricaoStatus
            DescricaoTipo
            botãoDeletar
            CodigoStatus
            CodigoTipo
            CodigoStatusTraducao
            CodigoIdioma
            */
            document.getElementById('hdnOperacao').value = 'a'; //determinar operação de alteração - npaulo/esertorio - 20080919
            document.getElementById('txtCodigo').value = pObjTR.childNodes[0].innerText;
            document.getElementById('hdnCodigo').value = pObjTR.childNodes[0].innerText;
            document.getElementById('ddlStatusMensagem').value = pObjTR.childNodes[9].innerText;
            
            document.getElementById('ddlModulo').value = pObjTR.childNodes[1].innerText;
            
            //document.getElementById('txtSubmodulo').value = pObjTR.childNodes[2].innerText; //exc - esertorio - 200810061254
            var objDdlSubModulo = document.getElementById('ddlSubModulo');
            var achou = false;
            for(var i = 0; i < objDdlSubModulo.options.length; i++)
            {
                if(objDdlSubModulo.options[i].text == pObjTR.childNodes[2].innerText)
                {
                    achou = true;
                    //alert('achou = true'); //debug
                    document.getElementById('ddlSubModulo').value = pObjTR.childNodes[2].innerText;
                    break;
                }
            }
            if(!achou)
            {
                //alert('achou = false'); //debug
                objDdlSubModulo.options[0] = new Option( pObjTR.childNodes[2].innerText, pObjTR.childNodes[2].innerText);
                objDdlSubModulo.options[0].selected = true;
            }
            
            //document.getElementById('ddlSubModulo').value = pObjTR.childNodes[2].innerText; //inc - esertorio - 200810061254
            
            document.getElementById('ddlTipoMensagem').value = pObjTR.childNodes[10].innerText;
            
            document.getElementById('hdnResourKeyCompleta').value = pObjTR.childNodes[17].innerText;
            document.getElementById('txtResourceKey').value = pObjTR.childNodes[17].innerText.substring(pObjTR.childNodes[17].innerText.lastIndexOf('.')+1);
            document.getElementById('txtPrefixoResourceKey').value = pObjTR.childNodes[17].innerText.substring(0, pObjTR.childNodes[17].innerText.lastIndexOf('.'));
            
            document.getElementById('txtProposito').value = pObjTR.childNodes[16].innerText;
            document.getElementById('txtMensagem').value = pObjTR.childNodes[15].innerText;
            
            //document.getElementById('lblStatusTraducao').style.display = 'block';
            //document.getElementById('lblIdioma').style.display = 'block';
            //document.getElementById('ddlStatusTraducao').style.display = 'block';
            //document.getElementById('ddlIdioma').style.display = 'block';
            document.getElementById('ddlStatusTraducao').value = pObjTR.childNodes[11].innerText;
            document.getElementById('ddlIdioma').value = pObjTR.childNodes[12].innerText;
        }
               
    </script>
</head>
<body style="width: 100%; height: 100%; margin: 0 0 0 0;">
    <form id="frmMensagem" runat="server"  style="width: 100%; height: 100%; margin: 0 0 0 0; ">
        <table style="width: 100%;height:45%" cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td style="width: 100%; height:15%" align="center">
                    <fieldset>
                        <legend><asp:Label ID="Label1" runat="server">Consulta de Mensagem</asp:Label></legend>
                        <table style="width: 100%;" cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <td style="width: 13%; " align="left" valign="top">                                    
                                     <table style="width: 100%; " cellpadding="0" cellspacing="0" border="0">
                                        <tr>
                                             <td align="left" valign="top">
                                                  <nobr>
                                                    <asp:RadioButton ID="rdoMensagem"    runat="server" Text ="Mensagem"  GroupName="Filtro" Checked="true" oncheckedchanged="rdoFiltro_CheckedChanged" AutoPostBack="true" /> 
                                                  </nobr>  
                                             </td>
                                             <td>&nbsp;</td>
                                             <td style="width: 55%;" align="left" valign="top">
                                                <nobr>     
                                                    <asp:RadioButton ID="rdoResourceKey" runat="server" Text ="ResourceKey" GroupName="Filtro" oncheckedchanged="rdoFiltro_CheckedChanged"  AutoPostBack="true"/>                                    
                                                </nobr>
                                             </td>
                                        </tr>
                                     </table>       
                                </td>
                                <td style="width: 50%;"  align="left" valign="top">
                                	<asp:TextBox ID="txtMensagem" runat="server" Enabled="true" MaxLength="200" 
                                        TextMode="MultiLine"  Columns="108" Rows="3" 
                                        ontextchanged="txtMensagem_TextChanged" ></asp:TextBox>
                                </td>
                                <td>&nbsp;</td>
                                <td align="left" valign="top">                                 
                                    <table cellpadding="0" cellspacing="0" border="0">
                                        <tr>
                                            <td><asp:Button ID="btnPesquisar" runat="server" Text="Pesquisar" Width="140px" onclick="btnPesquisar_Click" /></td><!-- OnClientClick="if(!ValidaCampos()){ return false;}"-->
                                        </tr>
                                        <tr>
                                            <td><asp:Button  ID="btnNovaPesquisa" runat="server" Text="Nova Pesquisa" Width="140px" onclick="btnNovaPesquisa_Click"/></td>
                                        </tr>
                                    </table>                                    
                                </td>                               
                            </tr>                                                                                   
                        </table>
                    </fieldset>
                </td>
            </tr>          
            <tr>
                 <td >
                     <table cellpadding="0" cellspacing="0" border="0" style="width:90%">
                        <tr>
                            <td style="text-align:center;" ><asp:Label ID="lblAvisoPesquisa" runat="server" 
                                    ForeColor="#3366FF" /></td>
                        </tr>
                     </table>
                 </td>
            </tr>   
                
            <tr style="height:100px">
                <td style="width: 50%;">
                    <fieldset style="height:280px;" >
                        <legend>Dados Mensagens</legend>
                            <table style="width: 100%; " cellpadding="0" cellspacing="0" border="0">
                        <tr>
                            <td style="width: 70%;" align="left" valign="top">                              
                                        <asp:GridView ID="grdMensagem" runat="server" AutoGenerateColumns="False" Width="100%" AllowPaging="True" AllowSorting="True" 
                                                      PageSize="12" BorderColor="Black" 
                                                     OnPageIndexChanging="grdMensagem_PageIndexChanging" OnSorting="grdMensagem_Sorting" 
                                                     OnRowDataBound="grdMensagem_RowDataBound" onselectedindexchanged="grdMensagem_SelectedIndexChanged" >
                                                 
                                                <PagerSettings Mode="Numeric" Position="Bottom" PageButtonCount="50" />
                                                
                                                <Columns>
                                                    <asp:CommandField CancelText="" DeleteText="" EditText="" InsertText="" 
                                                        NewText="" SelectText="Selecione" ShowSelectButton="True" UpdateText="" />
                                                    <asp:BoundField DataField="Id" HeaderText="Código" SortExpression="Id" 
                                                        ReadOnly="True" >
                                                        <FooterStyle HorizontalAlign="Right" />
                                                        <HeaderStyle Width="6%" />
                                                        <ItemStyle Width="6%" HorizontalAlign="Right" />
                                                    </asp:BoundField>
                                                    <asp:BoundField DataField="DescricaoMensagem" HeaderText="Descrição" 
                                                        SortExpression="Descricao" ReadOnly="True" >
                                                        <FooterStyle HorizontalAlign="Right" />
                                                        <HeaderStyle Width="80%" />
                                                        <ItemStyle Width="80%" HorizontalAlign="Left"/>
                                                    </asp:BoundField>
                                                    <asp:BoundField DataField="UsuarioLogadoMensagem" HeaderText="Usuário" 
                                                        SortExpression="UsuarioLogadoMensagem" ReadOnly="True" >
                                                        <HeaderStyle Width="10%" />
                                                        <ItemStyle Width="10%" HorizontalAlign="Left"/>
                                                    </asp:BoundField>
                                                    <asp:TemplateField HeaderText="Alterar">
                                                        <ItemTemplate><asp:ImageButton runat="server" ID="ImgAlterarMensagem" ImageUrl="~/Imagens/alterar.gif" onclick="AlterarMensagem_Click" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "Id")%>' />
                                                        </ItemTemplate>
                                                        <HeaderStyle Width="5%" />
                                                        <ItemStyle Width="5%" />
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="Deletar">
                                                        <ItemTemplate><asp:ImageButton runat="server" ID="ImgDeletarMensagem" ImageUrl="~/Imagens/delete.gif" OnClientClick="if(!ConfirmarDelete()){ return false;}" onclick="DeletarMensagem_Click" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "Id")%>' />
                                                        </ItemTemplate>
                                                        <HeaderStyle Width="5%" />
                                                        <ItemStyle Width="5%" />
                                                    </asp:TemplateField>                                                  
                                                    
                                                </Columns>
                                                <PagerStyle BackColor="#F0F0F0" />
                                                <HeaderStyle BackColor="#F0F0F0" />
                                        </asp:GridView>                                   
                            </td>
                            <td style="width: 10%; " align="left" valign="top">
                                <table style="width: 100%; " cellpadding="0" cellspacing="0" border="0">
                                    <tr>
                                         <td style="width: 50%;" align="left" valign="top">                                
                                            <asp:Button  ID="btnNovaMensagemResourceKey" runat="server" Text="Nova Men. e  Resource Key"  
                                                 Width="177px" onclick="btnNovaMensagemResourceKey_Click" ToolTip="Nova Mensagem e ResourceKey"
                                                 Enabled ="false" />
                                        </td>
                                    </tr>
                                 </table>   
                            </td>
                        </tr>
                    </table>            
                    </fieldset>
                </td>                
            </tr>  
            <tr>
                 <td  style="padding-left:450px;text-align:left; ">
                     <asp:Label ID="lblAvisoMensagem" runat="server" Text="" />
                 </td>
            </tr>                
            <tr>                
                <td style="width: 50%;height:100px">
                    <fieldset style="height:272px;" >
                        <legend>Dados ResouceKey</legend>
                            <table style="width: 100%; " cellpadding="0" cellspacing="0" border="0">
                        <tr>
                            <td style="width: 70%; height: 50%; " align="left" valign="top">                                    
                                        <asp:GridView ID="grdResourceKey" runat="server" AutoGenerateColumns="False"  Width="100%" AllowPaging="True" AllowSorting="True"
                                                      PageSize="12" BorderColor="Black" 
                                                      OnPageIndexChanging="grdResouceKey_PageIndexChanging" 
                                                      OnSorting="grdResouceKey_Sorting" 
                                                      OnRowDataBound="grdResourceKey_RowDataBound" 
                                                      OnSelectedIndexChanged="grdResourceKey_SelectedIndexChanged">
                                                <PagerSettings Mode="Numeric" Position="Bottom" />
                                                <Columns>
                                                     <asp:CommandField CancelText="" DeleteText="" EditText="" InsertText="" 
                                                        NewText="" SelectText="Selecione" ShowSelectButton="True" UpdateText="" />
                                                    <asp:BoundField DataField="Id" HeaderText="Código" SortExpression="Id" >
                                                        <HeaderStyle Width="6%" />
                                                        <ItemStyle Width="6%" HorizontalAlign="Right" />
                                                    </asp:BoundField>
                                                    <asp:BoundField DataField="ResourceKey" HeaderText="Descrição" SortExpression="Descricao" >
                                                        <HeaderStyle Width="80%" />
                                                        <ItemStyle Width="80%" HorizontalAlign="Left"/>
                                                    </asp:BoundField>
                                                    <asp:BoundField DataField="UsuarioLogado" HeaderText="Usuário" SortExpression="Usuario" >
                                                        <HeaderStyle Width="10%" />
                                                        <ItemStyle Width="10%" HorizontalAlign="Left"/>
                                                    </asp:BoundField>
                                                    <asp:TemplateField HeaderText="Alterar">
                                                        <ItemTemplate><asp:ImageButton runat="server" ID="ImgAlterarResourceKey" ImageUrl="~/Imagens/alterar.gif" onclick="AlterarResourceKey_Click" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "Id")%>' />
                                                        </ItemTemplate>
                                                        <HeaderStyle Width="5%" />
                                                        <ItemStyle Width="5%" />
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="Deletar">
                                                        <ItemTemplate><asp:ImageButton runat="server" ID="ImgDeletarResourceKey" ImageUrl="~/Imagens/delete.gif" OnClientClick="if(!ConfirmarDelete()){ return false;}" onclick="DeletarResourceKey_Click" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "Id")%>' />
                                                        </ItemTemplate>
                                                        <HeaderStyle Width="5%" />
                                                        <ItemStyle Width="5%" />
                                                    </asp:TemplateField>
                                                </Columns>
                                                <PagerStyle BackColor="#F0F0F0" />
                                                <HeaderStyle BackColor="#F0F0F0" />
                                        </asp:GridView>                                   
                            </td>
                            <td style="width: 10%; " align="left" valign="top">
                                <table style="width: 100%; " cellpadding="0" cellspacing="0" border="0">
                                    <tr>
                                         <td style="width: 50%;" align="left" valign="top">                                
                                            <asp:Button  ID="btnNovaResourceKey" runat="server" Text="Nova ResourceKey" 
                                                 Width="177px" onclick="btnNovaResourceKey_Click" ToolTip ="Nova ResourceKey"
                                                 Enabled ="false" />
                                        </td>
                                    </tr>
                                 </table>    
                            </td>
                        </tr>
                    </table>            
                    </fieldset>
                </td>                
            </tr>    
            <tr>
                 <td  style="padding-left:400px;text-align:left; ">
                     <asp:Label ID="lblAvisoResourceKey" runat="server" Text="" ForeColor="Red" />
                 </td>   
            </tr>               
        </table>
    </form>
</body>
</html>
